﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WorkStation.Frameworks.Core.Extensions
{
    public static class BoolExtensions
    {
        public static bool WhenTrue(this bool input, Action action) 
        {
            if (input) 
            {
                action();
            }

            return input;
        }

        public static T WhenTrue<T>(this bool input, Func<T> func)
        {
            if (input)
            {
                return func();
            }
            else
            {
                return default(T);
            }
        }

        public static bool WhenFalse(this bool input, Action action) 
        {
            if (!input) 
            {
                action();
            }

            return input;
        }

        public static T WhenFalse<T>(this bool input, Func<T> func) 
        {
            if (!input)
            {
                return func();
            }
            else 
            {
                return default(T);
            }
        }
    }
}
